﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;

namespace TreasureHunter
{
    public partial class Form1 : Form
    {
        private Board gameBoard;

        public Form1()
        {
            InitializeComponent();
            SetDoubleBuffered(panelBoard);
            TextureLoader.LoadTextures();
            gameBoard = new Board(this);
        }

        /// <summary>
        /// Enabled double buffering for a control.
        /// </summary>
        /// <param name="control">Control that will use double buffering</param>
        public static void SetDoubleBuffered(Control control)
        {
            // set instance non-public property with name "DoubleBuffered" to true
            typeof(Control).InvokeMember("DoubleBuffered",
                BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                null, control, new object[] { true });
        }

        private void panelBoard_Paint(object sender, PaintEventArgs e)
        {
            gameBoard.Draw(e);
        }
    }
}
